home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / strstrea.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  7.1 KB  |  242 lines

  1. #ifndef __STD_STRSTREAM__
  2. #define __STD_STRSTREAM__
  3. #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
  4.  
  5. /***************************************************************************
  6.  *
  7.  * strstream - Declarations for the Standard Library string stream classes
  8.  *
  9.  * $Id: strstream,v 1.25 1996/08/28 18:43:49 smithey Exp $
  10.  *
  11.  ***************************************************************************
  12.  *
  13.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  14.  * ALL RIGHTS RESERVED *
  15.  * The software and information contained herein are proprietary to, and
  16.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  17.  * intends to preserve as trade secrets such software and information.
  18.  * This software is furnished pursuant to a written license agreement and
  19.  * may be used, copied, transmitted, and stored only in accordance with
  20.  * the terms of such license and with the inclusion of the above copyright
  21.  * notice.  This software and information or any other copies thereof may
  22.  * not be provided or otherwise made available to any other person.
  23.  *
  24.  * Notwithstanding any other lease or license that may pertain to, or
  25.  * accompany the delivery of, this computer software and information, the
  26.  * rights of the Government regarding its use, reproduction and disclosure
  27.  * are as set forth in Section 52.227-19 of the FARS Computer
  28.  * Software-Restricted Rights clause.
  29.  *
  30.  * Use, duplication, or disclosure by the Government is subject to
  31.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  32.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  33.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  34.  * P.O. Box 2328, Corvallis, Oregon 97339.
  35.  *
  36.  * This computer software and information is distributed with "restricted
  37.  * rights."  Use, duplication or disclosure is subject to restrictions as
  38.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  39.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  40.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  41.  * then the "Alternate III" clause applies.
  42.  *
  43.  **************************************************************************/
  44.  
  45. #include <streambuf>
  46. #include <istream>
  47. #include <ostream>
  48.  
  49. #ifndef _RWSTD_NO_NAMESPACE 
  50. namespace std {
  51. #endif
  52.   
  53.  
  54. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  55.   class _RWSTDExport strstreambuf : public basic_streambuf<char>
  56.   {
  57. #else
  58.   class _RWSTDExport strstreambuf : public basic_streambuf<char, char_traits<char> >
  59.   {
  60. #endif // _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES 
  61.  
  62.    public:
  63.     //
  64.     // Types:
  65.     //
  66.     typedef char                         char_type;
  67.     typedef char_traits<char>            traits;
  68.     typedef traits::int_type             int_type;
  69.     typedef traits::pos_type             pos_type;
  70.     typedef traits::off_type             off_type;
  71.   
  72.     _EXPLICIT strstreambuf(streamsize alsize = 0);
  73.     strstreambuf(void *(*palloc)(size_t), void (*pfree)(void *));
  74.     strstreambuf(char *gnext, streamsize n, char *pbeg = 0);
  75.  
  76.     strstreambuf(unsigned char *gnext, streamsize n,
  77.                        unsigned char *pbeg = 0);
  78.     strstreambuf(signed char *gnext, streamsize n,
  79.                        signed char *pbeg = 0);
  80.  
  81.     strstreambuf(const char *gnext, streamsize n);
  82.     strstreambuf(const unsigned char *gnext, streamsize n);
  83.     strstreambuf(const signed char *gnext, streamsize n);
  84.     virtual ~strstreambuf();
  85.  
  86.     void freeze(bool f = 1);
  87.     char *str();
  88.     int pcount() const;
  89.  
  90. protected:
  91.     virtual int_type overflow(int_type c = traits::eof());
  92.     virtual int_type pbackfail(int_type c = traits::eof());
  93.     virtual int_type underflow();
  94.  
  95.   virtual pos_type seekoff(off_type, ios_base::seekdir way,
  96.                              ios_base::openmode which =
  97.                                ios_base::in | ios_base::out);
  98.  
  99.     virtual pos_type seekpos(pos_type sp, ios_base::openmode which =
  100.                              ios_base::in | ios_base::out);
  101.  
  102.     virtual streambuf* setbuf(char *s, streamsize n);
  103.     virtual streamsize xsputn(const char_type *s, streamsize n);
  104.  
  105.   private:
  106.     typedef long strstate;
  107.  
  108.     enum str_state {
  109.       allocated      = 0x01,
  110.       constant       = 0x02,
  111.       dynamic        = 0x04,
  112.       frozen         = 0x08
  113.     };
  114.  
  115.     int doallocate();
  116.   
  117.     strstate       __strmode;
  118.     streamsize     __alsize;
  119.     char          *__data;
  120.     streamsize     __end_pos;
  121.  
  122.     void           *(*__palloc)(size_t);
  123.     void           (*__pfree)(void *);
  124.  };
  125.  
  126.  
  127. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  128. class _RWSTDExport istrstream : public basic_istream<char>
  129. {
  130. #else
  131. class _RWSTDExport istrstream : public basic_istream<char, char_traits<char> >
  132. {
  133. #endif
  134.  
  135.   public:
  136.     //
  137.     // Types:
  138.     //
  139.     typedef char                         char_type;
  140.     typedef char_traits<char>            traits;
  141.     typedef traits::int_type             int_type;
  142.     typedef traits::pos_type             pos_type;
  143.     typedef traits::off_type             off_type;
  144.   
  145.     _EXPLICIT istrstream(const char *s);
  146.     istrstream(const char *s, streamsize n);
  147.     _EXPLICIT istrstream(char *s);
  148.     istrstream(char *s, streamsize n);
  149.  
  150.     virtual ~istrstream();
  151.  
  152.     strstreambuf *rdbuf() const;
  153.     char *str();
  154.   protected:
  155.  
  156.   private:
  157.     strstreambuf              __sb;
  158. };
  159.  
  160. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  161.   class _RWSTDExport ostrstream : public basic_ostream<char>
  162.   {
  163. #else
  164.   class _RWSTDExport ostrstream : public basic_ostream<char, char_traits<char> >
  165.   {
  166. #endif
  167.  
  168.   public:
  169.     //
  170.     // Types:
  171.     //
  172.     typedef char                               char_type;
  173.     typedef char_traits<char>                  traits;
  174.     typedef traits::int_type                   int_type;
  175.     typedef traits::pos_type                   pos_type;
  176.     typedef traits::off_type                   off_type;
  177.   
  178.     ostrstream();
  179.     ostrstream(char *s, int n,
  180.                      ios_base::openmode = ios_base::out);
  181.     
  182.     virtual ~ostrstream();
  183.     strstreambuf *rdbuf() const;
  184.     void freeze(int freezefl = 1);
  185.     char *str();
  186.     int pcount() const;
  187.  
  188.   protected:
  189.  
  190.   private:
  191.     strstreambuf        __sb;
  192. };
  193.  
  194.  
  195. /*
  196.  *  Class strstream
  197.  */
  198.  
  199. #ifndef _RWSTD_NO_DEFAULT_TEMPLATES
  200.   class _RWSTDExport strstream : public basic_iostream<char>
  201.   {
  202. #else
  203.   class _RWSTDExport strstream : public basic_iostream<char, char_traits<char> >
  204.   {
  205. #endif
  206.  
  207.   public:
  208.     //
  209.     // Types:
  210.     //
  211.     typedef char                         char_type;
  212.     typedef char_traits<char>            traits;
  213.     typedef traits::int_type             int_type;
  214.     typedef traits::pos_type             pos_type;
  215.     typedef traits::off_type             off_type;
  216.   
  217.     strstream();
  218.     strstream(char *s, int n,
  219.               ios_base::openmode = ios_base::out | ios_base::in);
  220.  
  221.     void freeze(int freezefl = 1);
  222.     int pcount() const;
  223.  
  224.     virtual ~strstream();
  225.     strstreambuf *rdbuf() const;
  226.  
  227.     char *str();
  228.   protected:
  229.  
  230.   private:
  231.     strstreambuf          __sb;
  232.   };
  233.  
  234.  
  235. #ifndef _RWSTD_NO_NAMESPACE
  236. }
  237. #endif
  238.  
  239. #pragma option pop
  240.  
  241. #endif //__STD_STRSTREAM__
  242.